const net=require("net");

var server=net.createServer();
server.on("connection",(socket)=>{
	socket.write("hello,i am matrix!!!\n");
	socket.on("data",function(chunk){
		var s=chunk.toString();
		if(s.indexOf("bye")>=0){
			socket.destroy();
		}
		socket.write("hello:"+s+"\n");
	})
	//socket.destroy();
});

server.listen(5001,(err)=>{
	if(!err){
		console.log("chat server start on 5000");
	}
})